package com.zzw.grpc;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Administrator
 */
@Configuration
@EnableConfigurationProperties({GrpcClientProperties.class, GrpcServerProperties.class})
@ConditionalOnProperty(prefix = "com.zzw.grpc", name = "enable")
public class GrpcConfiguration {

    public DefaultGrpcServer defaultGrpcServer(GrpcServerProperties serverProperties) {
        return new DefaultGrpcServer(serverProperties);
    }

    @Bean
    @ConditionalOnMissingBean
    public DefaultGrpcClient defaultGrpcClient(GrpcClientProperties clientProperties) {
        return new DefaultGrpcClient(clientProperties);
    }
}
